<script lang="jsx" setup>
import { ref } from 'vue';
import { auditDeleteService, auditGetByCondService, auditGetListService } from '@/api/audit';

const columns = ref([
  {
    dataKey: "id",
    title: "id",
    width: 100
  },
  {
    dataKey: "adminId",
    title: "管理员id",
    width: 100
  },
  {
    dataKey: "requestMethod",
    title: "请求方法",
    width: 120
  },
  {
    dataKey: "requestPath",
    title: "请求路径",
    width: 200
  },
  {
    dataKey: "requestBody",
    title: "请求体",
    width: 520,
    isCopy: true
  },
  {
    dataKey: "createdTime",
    title: "操作时间",
    width: 200
  }
])

const getAuditList = async (lastMaxId) => {
  return await auditGetListService(lastMaxId)
}

const onDelete = async (rowId) => {
  await auditDeleteService(rowId);
}

/* 搜索 */
const searchPair = {
  "id": "id",
  "管理员id": "adminId",
  "请求方法": "requestMethod",
  "请求路径": "requestPath",
  "注册时间": "createdTime"
}

const onSearch = async(formObj) => {
  return await auditGetByCondService(formObj);
}
</script>

<template>
  <table-warpper 
    :select-data="getAuditList" :delete-data="onDelete" :columns="columns"
    search-title="搜索审计" :search-data="onSearch" :search-pair="searchPair"
  ></table-warpper>
</template>